package com.gcloud.googledrive;

import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

public class GoogleHandler {

	private GoogleAccountCredential credential;
	private static Drive service;
	private String account;
	Context context;

	public GoogleHandler() {
	}

	public GoogleHandler(Context context, String account) {
		this.account = account;
		this.context = context;
	}

	public void uploadFile() {

	}

	public void listFiles() {

	}

	public void dowloadFile() {

	}

	private boolean authenticateOnService(String account) {
		credential = GoogleAccountCredential.usingOAuth2(context,
				DriveScopes.DRIVE);
		credential.setSelectedAccountName(account);
		service = getDriveService(credential);
		if (service != null) {
			return true;
		}
		return false;
	}

	private Drive getDriveService(GoogleAccountCredential credential) {
		return new Drive.Builder(AndroidHttp.newCompatibleTransport(),
				new GsonFactory(), credential).build();
	}

}
